<?php

use yii\db\Migration;

class m000000_000012_create_user_account extends Migration
{
    public function up()
    {
        $this->createTable('{{%user_account}}', [
            'id'=>$this->primaryKey(), // PK
            'uid'=>$this->integer(), // 用户编号
            'money'=>$this->decimal(12, 2), // 现金
            'freeze_money'=>$this->decimal(12, 2), // 冻结现金
            'score'=>$this->integer(), // 消费积分
            'point'=>$this->integer(), // 等级积分
        ]);
        $this->createIndex('fk_user_account_user1_idx', '{{%user_account}}', ['uid']);
        try {
            $this->addForeignKey('fk_user_account_user1', '{{%user_account}}', ['uid'], '{{%user}}', ['id']);
        } catch (Exception $e) {
        }
    }

    public function down()
    {
        $this->dropTable('{{%user_account}}');
    }
}
